<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix = "c" uri="http://java.sun.com/jsp/jstl/core" %>
<jsp:useBean id="manager" class="beans.IndexBean" scope="request" >
	<c:set target="${manager}" property="request" value="${pageContext.request}"></c:set>
	<c:set target="${manager}" property="response" value="${pageContext.response}"></c:set>
</jsp:useBean>
<c:set var="personsList"  value="${manager.persons}" ></c:set>
<jsp:include page="header.jsp" />

<c:choose>
	<c:when test="${manager.error}">
		${manager.bookerrorvalidator.erroretring}
	</c:when>
	<c:otherwise>
		<c:if test="${param.action == 'del'}">
			${manager.delPerson}
		</c:if>
		<c:if test="${param.action == 'edit'}">
			<c:redirect url="edit.jsp?id=${param.id}" />
		</c:if>
		<div class="div_center">
		 <form id="indexForm" method="post" action="">
			<table id="allUsers">
			    <tr>
			        <td><input type="checkbox" onClick="selectAll(this)" /></td>
			        <td>Имя</td>
			        <td>Фамилия</td>
			        <td>Отчество</td>
			        <td>Телефон мобильный</td>
			        <td>Телефон домашний</td>
			        <td>Адрес</td>
			        <td>Email</td>
			    </tr>
			    <c:forEach var="person" items="${personsList}" >
			      <tr>
				        <td><input type="checkbox" name="selectUsers" value="${person.id}"></td>
				        <td class="rowCell">${person.name}</td>
				        <td class="rowCell">${person.surname}</td>
				        <td class="rowCell">${person.middlename}</td>
				        <td class="rowCell">${person.mobile}</td>
				        <td class="rowCell">${person.phonehome}</td>
				        <td class="rowCell">${person.mail}</td>
				        <td class="rowCell">${person.address}</td>
			   	  </tr>
			    </c:forEach>
			</table>
					<input type="submit" name="btnAdd" formaction="add.jsp" value="Добавить"  />
			</form>
			<input type="submit" name="btnDelete" value="Удалить" onClick="btnDelClick()" />
		</div>
	</c:otherwise>			
</c:choose> 

<jsp:include page="footer.jsp" />